package com.example.classwork;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import java.text.DecimalFormat;

public class InputActivity extends AppCompatActivity {
private static final String TAG="Main";
EditText update_dollar;
EditText update_euro;
EditText update_won;
float dollar3 ;
float euro3;
 float won3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_input);
        Intent intent=getIntent();

        dollar3=intent.getFloatExtra("dollar_rate_key",0.0f);
        euro3=intent.getFloatExtra("euro_rate_key",0.0f);
        won3=intent.getFloatExtra("won_rate_key",0.0f);

        Log.i(TAG,"onCreate: dollarRate=" +dollar3 );
        Log.i(TAG,"onCreate: euroRate=" +euro3);
        Log.i(TAG,"onCreate: wonRate="+won3);

        update_dollar = findViewById(R.id.update_dollar);
        update_euro = findViewById(R.id.update_euro);
        update_won = findViewById(R.id.update_won);

        update_dollar.setText(String.valueOf(dollar3));
        update_euro.setText(String.valueOf(euro3));
        update_won.setText(String.valueOf(won3));
    }


    public void save(View btn){
        Log.i(TAG,"save:");


        String d3=update_dollar.getText().toString();
        String e3=update_euro.getText().toString();
        String w3=update_won.getText().toString();

        Log.i(TAG,"save: d3=" +d3 );
        Log.i(TAG,"save: e3=" +e3);
        Log.i(TAG,"save: w3="+w3);

        Intent intent =getIntent();

       Bundle bundle=new Bundle();

 bundle.putFloat("dollar_rate_key1",Float.parseFloat(d3));
 bundle.putFloat("euro_rate_key1",Float.parseFloat(e3));
 bundle.putFloat("won_rate_key1",Float.parseFloat(w3));
     intent.putExtras(bundle);
     setResult(6,intent);
     finish();
        }
}